# deal data

data_list =[]

with open('Iris.txt', 'r') as f:
    dataline = f.readlines()
    for d in dataline:
        dl = d.split(",")
        data = []
        for i in dl:
            if i == "Iris-setosa\n":
                data.append("0")
            elif i == "Iris-versicolor\n":
                data.append("1")
            elif i == "Iris-virginica\n":
                data.append("2")
            else:
                data.append(i)
        data_list.append(data)

# for i in range(4):
#     print(data_list[i])



# write data to file
with open('dealdata.txt', 'w') as f:
    for d in data_list:
        idx = 0
        for i in d:
            f.write(i)
            if idx < 4:
                f.write(",")
            idx += 1
        f.write("\n")
        
